package com.software_product_construction.backend_software_product_construction.controller;

import com.software_product_construction.backend_software_product_construction.pojo.Lessee;
import com.software_product_construction.backend_software_product_construction.pojo.User;
import com.software_product_construction.backend_software_product_construction.service.impl.SuperServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping(value = "/super")
public class SuperController {
    @Autowired
    SuperServiceImpl superService;

    @GetMapping(value= "/deleteLesseeById")
    public Boolean deleteLesseeById(@RequestParam("id") String id){
        return superService.deleteLesseeById(id);
    }

    @PostMapping(value = "/modifyLesseeInfo")
    public Boolean modifyLesseeInfo(@RequestBody Map<String, Object> map){
        String id = (String) map.get("id");
        String password = (String) map.get("password");
        String nickname = (String) map.get("nickname");
        Integer sex = (Integer) map.get("sex");
        System.out.println(id);
        return superService.modifyLesseeInfo(id, password,nickname, sex);
    }

    @GetMapping(value = "/getLesseeList")
    public List<Lessee> getLesseeList(@RequestParam("name") String name, @RequestParam("from")Integer from, @RequestParam("to")Integer to){
        return superService.getLesseeList(name, from, to);
    }

    @GetMapping(value = "/getUserList")
    public List<User> getUserList(@RequestParam("name") String name, @RequestParam("from")Integer from, @RequestParam("to")Integer to){
        return superService.getUserList(name, from, to);
    }
}
